<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        {{num}}
        <hr />
        {{shop.cart.count}}
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          num: 10,
          shop: {
            title: "hello",
            cart: {
              count: 10,
            },
          },
        },
        watch: {
          "shop.cart.count"(newValue, oldValue) {
            console.log(newValue, oldValue);
          },
        },
        created() {
          setInterval(() => {
            this.shop.cart.count++;
          }, 1000);
        },
      });
    </script>
  </body>
</html>
